<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let str = '张三丰(1)';
    let index = str.indexOf('('); // 获取左括号的位置
    let result = str.substring(0, index); // 使用substring()方法截取左括号之前的字符串
    // 或者使用slice()方法
    // let result = str.slice(0, index);
    console.log(result); // 输出'张三丰'
  </script>
</body>

</html>